import type {
  StudentAddDTOType,
  StudentUpdateDTOType,
  StudentSearchDTOType
} from '@/resources/interface/student/StudentTypes'
import type { ResultTypes } from '@/resources/interface/ResultTypes'
import { HttpResultUtil } from '@/apis/utils/HttpResultUtil'

export class StudentApi {
  private static addUrl: string = '/student/add'
  private static updateUrl: string = '/student/update'
  private static searchUrl: string = '/student/search'
  private static deleteUrl: string = '/student/delete'

  static add(data: StudentAddDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.addUrl, data,true)
  }

  static update(data: StudentUpdateDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.updateUrl, data,true)
  }

  static search(data: StudentSearchDTOType): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.searchUrl, data,false)
  }

  static delete(idList: Array<number>): Promise<ResultTypes> {
    return HttpResultUtil.awaitPost(this.deleteUrl, idList,true)
  }
}
